// Vowels and Consonants counter
// Date 08/10/2018
// By Ben

#include <iostream>

using namespace std;
using std::cout;
using std::endl;
using std::cin;

void countLetters(string source, int &Vowels, int &Consonant){
	int i = 0;
	int nVowels = 0;
	int nConsonant = 0;
	//Loop to the end of the string
	while (i < source.length()){
		//Convert all chars to uppercase and check for vowels
		switch (toupper(source[i]))
		{
		case 'A':
		case 'E':
		case 'I':
		case 'O':
		case 'U':
			//INC vowels counter
			nVowels++;
			break;
		default:
			//count consonants
			if (isalpha(source[i])){
				nConsonant++;
			}
			break;
		}
		//INC counter
		i++;
	}
	//Return counters
	Vowels = nVowels;
	Consonant = nConsonant;
}

int main(int argc, char *argv[]){
	string s0 = "This example counts all vowels and consonants in a string";
	int v, c;
	std::cout << "Input string: " << s0.c_str() << endl;

	//Count up vowels and consonants.
	countLetters(s0, v, c);

	//Display count found.
	std::cout << "Vowel     : " << v << endl;
	std::cout << "Consonant : " << c << endl;
	system("pause");
	return 0;
}